Use EVP_PKEY_check() for check_key() on OpenSSL 3.x#201
Draft
toddr-bot wants to merge 1 commit into
Draft
Conversation
EVP_PKEY_private_check() only validates CRT parameters and d*e congruence. RSA_check_key() (used on pre-3.x) additionally checks primality of p/q and n==p*q. OpenSSL's migration guide explicitly recommends EVP_PKEY_check() as the replacement. Also clear the error queue after a failed check to prevent stale errors from corrupting subsequent croakSsl() messages. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Replace
EVP_PKEY_private_check()withEVP_PKEY_check()incheck_key()on OpenSSL 3.x, and clear the error queue after a failed check.Why
EVP_PKEY_private_check()only validates CRT parameters and de ≡ 1 mod λ(n). The pre-3.xRSA_check_key()it replaced also verifies primality of p/q, n == pq, and other structural checks. OpenSSL's migration guide explicitly recommendsEVP_PKEY_check()as the replacement forRSA_check_key(). Using the weaker function is a silent validation regression — keys with corrupt public components would passcheck_key()on 3.x but fail on pre-3.x.How
EVP_PKEY_private_check(pctx)→EVP_PKEY_check(pctx)(one-line change in RSA.xs)ERR_clear_error()after a failed check on both code paths to prevent stale errors from corrupting subsequentcroakSsl()messagesTesting
Full test suite passes (667 tests). The existing
t/check_param.texercisescheck_key()on valid and invalid keys.🤖 Generated with Claude Code
Quality Report
Changes: 2 files changed, 3 insertions(+), 2 deletions(-)
Code scan: clean
Tests: passed (OK)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline